<!DOCTYPE HTML>
<html  xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
<title>添加</title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form form form-horizontal"  id="form-task-add" action="#" th:action="@{/task/task/add}">
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>添加任务类型：</label>
                        <div class="layui-input-inline">
<!--                            <input type="layui-input" class="layui-input"  name="taskType"  placeholder="修改添加任务类型(1今日任务，2本周任务，3月计划，4.年计划）" id="taskType"/>-->
                            <select class="layui-input" name="taskType" id="taskType">
                                <option value="">选择任务类型</option>
                                <option value="1">每日任务</option>
                                <option value="2">每周任务</option>
                            </select>
                        </div>
                        </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>任务标题：</label>
                        <div class="layui-input-inline">

                        <input type="layui-input" class="layui-input"  name="taskTitle"  placeholder="输入任务标题" id="taskTitle"/>
                        </div>
                        </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>任务内容：</label>
                <div class="layui-input-block" >
                    <script id="editor" name="taskContent"  type="text/plain"  style="height:500px;">
                    </script>
                    </div>
                        </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>任务完成情况：</label>
                        <div class="layui-input-inline">
                            <select class="layui-input" name="taskStatus" id="taskStatus">
                                <option value="">选择任务完成情况</option>
                                <option value="0">未完成的任务</option>
                                <option value="1">已完成的任务</option>
                            </select>
                        </div>
                        </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>任务创建人的id：</label>
                <div class="layui-input-inline">
                    <input type="layui-input" class="layui-input" th:value="${userId}"  name="userId"  placeholder="请输入任务创建人的id" id="userId" disabled/>
                </div>
            </div>

            
            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button  class="layui-btn" id="subbtn" type="submit" >
                    确认
                </button>
                <button  class="layui-btn" id="reset" type="reset" >
                    重置
                </button>
            </div>
        </form>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs"></div>
<div th:replace="_ueditor :: ueditor"></div>
 <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script>
    layui.use(['form', 'layer','laydate'],function() {
        $ = layui.jquery;
        var form = layui.form,
            laydate = layui.laydate,
            layer = layui.layer;
        lay('.timeSpace').each(function(){
            laydate.render({
                elem: this
                ,trigger: 'click'
                ,type: 'datetime'
            });
        });
    });

 $(function(){
	$("#form-task-add").validate({
		rules:{
            taskType:{
                required: true,
			},
            taskTitle:{
                required: true,
			},
            taskContent:{
                required: true,
			},
            taskStatus:{
                required: true,
			},
            userId:{
                required: true,
			},
            creatTime:{
                required: true,
			},
            deleteTime:{
                required: true,
			},
            deleteStatus:{
                required: true,
			},
		},
		onkeyup:false,
		debug: true,
		success:"valid",
		submitHandler:function(form){
				$(form).ajaxSubmit({
				type: 'POST',
				url: "/task/task/add" ,
				success: function(data){
					if(data.code == "1"){
						selfmsg('添加成功!',1,function(){
							var index = parent.layer.getFrameIndex(window.name);
							parent.location.reload();
							parent.layer.close(index);
						});
					}else{
						selfmsg('添加失败!');
					}
				},
                error: function(){
					selfmsg('添加异常!',5);
				}
			});
		}
	});
});

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>